#!ipxe

goto ${menu} ||

:live_menu
set os elementary OS
menu ${os}
item --gap ${os} Versions
{% for key, value in endpoints.items() | sort %}
{% if value.os == "elementary-os" %}
item {{ key }} ${space} ${os} {{ value.version }}
{% endif %}
{% endfor %}
choose live_version || goto live_exit
goto ${live_version}

{% for key, value in endpoints.items() | sort %}
{% if value.os == "elementary-os" and 'squash' in key %}
{% set kernel_name = value.kernel %}
:{{ key }}
set squash_url ${live_endpoint}{{ value.path }}filesystem.squashfs
{% for key, value in endpoints.items() | sort %}
{% if key == kernel_name %}
set kernel_url ${live_endpoint}{{ value.path }}
{% endif %}
{% endfor %}
goto boot
{% endif %}
{% endfor %}

:boot
imgfree
kernel ${kernel_url}vmlinuz ip=dhcp boot=casper maybe-ubiquity netboot=url url=${squash_url} {{ kernel_params }}
initrd ${kernel_url}initrd
boot

:live_exit
clear menu
exit 0
